package com.globopt.global.algorithm;

import com.globopt.global.algorithm.functions.F1;
import com.globopt.global.algorithm.functions.F2;
import com.globopt.global.algorithm.functions.F3;
import com.globopt.global.algorithm.functions.F4;

/**
 * This is the main class contains some examples how to setup the program.
 * 
 * @author Richard Gasztany 2012.11.29.
 * 
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		// example 1
		System.out.println("example 1");
		System.out.println("");
		Opts opts = new Opts();
		opts.setN(10);
		opts.setMaximumFunctionEvaluation(100000);
		opts.setGammak(0.99);
		opts.setRk(1.0e-6);
		opts.setMaximumNumberOfLocalMinimum(2);
		Method method = new Unirandi(1000);
		opts.setMethod(method);

		Function f1 = new F1();
		double[] lb = { -2.0, -2.0 };
		double[] ub = { 2.0, 2.0 };
		Global global = new Global(f1, opts, lb, ub);
		global.calculate();

		System.out.println("");
		System.out.println("example 2");
		System.out.println("");
		// example 2
		Opts opts2 = new Opts();
		opts2.setN(100);
		opts2.setMaximumFunctionEvaluation(10000);
		opts2.setGammak(0.7);
		opts2.setRk(1.0e-6);
		opts2.setMaximumNumberOfLocalMinimum(10);

		Function f2 = new F2();
		double[] lb2 = { -10.0, -10.0 };
		double[] ub2 = { 10.0, 10.0 };
		global = new Global(f2, opts2, lb2, ub2);
		global.calculate();

		// example 3
		System.out.println("");
		System.out.println("example 3");
		System.out.println("");
		Function f3 = new F3();
		double[] lb3 = { -10.0, -10.0, -10.0 };
		double[] ub3 = { 10.0, 10.0, 10.0 };
		global = new Global(f3, opts2, lb3, ub3);
		global.calculate();

		// example 4
		System.out.println("");
		System.out.println("example 4");
		System.out.println("");
		Function f4 = new F4();
		double[] lb4 = { -10.0 };
		double[] ub4 = { 10.0 };
		global = new Global(f4, opts2, lb4, ub4);
		global.calculate();

	}
}
